clear all; clc; close all;
R=120;
C=33e-12;
L=100e-6;
tau=R*C;
T=tau/300;
t=0:T:(100*tau);
N=length(t);
omega=1e09;

omega = 2*pi * ((1/tau/100):(1/tau / 100):(1/tau/2));
M = length(omega);

    Uc = zeros(1, N);
    S = zeros(1, N);
    i=zeros(1, N);
    Ur=zeros(1, N);
    
for l = 1:M

    for k=2:N;
 S(k)=sin(k*T*omega(l));
 Uc(k)=Uc(k-1)+i(k-1)*T/C;
 i(k)=(S(k)*T+L*i(k-1)-Uc(k)*T)/(L+R*T);
 Ur(k)=i(k)*R;
    end;
    K(l) = (max(Ur) - min(Ur))/2;
end


figure(1);
plot(omega/2/pi, K)
xlabel('f, Hz')
ylabel('|K(j\omega)|')
gridon